package secondriver.springsubway.event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.util.ClassUtils;

/**
 * @author secondriver
 * @created 2015年4月18日 上午10:23:42
 * 
 */
public class SimpleEventListener implements
        ApplicationListener<ApplicationEvent>{

	/**
	 * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent)
	 * @param event
	 */
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (ClassUtils.isAssignableValue(HelloSource.class, event.getSource())) {
			System.out
			        .println(ClassUtils.getDescriptiveType(event.getSource()));
			System.out.println("Recevied event SimpleEvent.");
			((HelloSource) event.getSource()).say("onApplicationEvent");
		} else {
			System.out.println("Not Recevied event SimpleEvent.");
			System.out
			        .println(ClassUtils.getDescriptiveType(event.getSource()));
		}
		System.out.println();
	}
}
